<template>
  <h1>表格组件</h1>
  <el-table :data="tableData" style="width: 600px;margin: 0 auto;">
    <el-table-column label="编号" type="index" width="180"/>
    <el-table-column prop="date" label="Date" width="180"/>
    <el-table-column prop="name" label="Name" width="180"/>
    <el-table-column prop="address" label="Address"/>
  </el-table>
  <el-table :data="Employee" style="width: 600px;margin: 0 auto;">
    <el-table-column label="姓名" prop="name" width="180"/>
    <el-table-column label="工资" prop="salary" width="180"/>
    <el-table-column label="职位" prop="job"/>
    <el-table-column label="操作" width="180">
      <template #default="scope">
        <el-button type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

</template>

<script setup>

import {ref} from "vue";

const tableData = ref(
    [
      {
        date: '2016-05-03',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-02',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-04',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      },
      {
        date: '2016-05-01',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
      }
    ]
);
//定义员工数据数组
const Employee = ref([
  {
    name: '张三',
    salary: '5000',
    job: '饲养员'
  },
    {
      name: '李四',
      salary: '4000',
      job: '保洁员'
    },
    {
      name: '王五',
      salary: '6000',
      job: '护林员'
    },
    {
      name: '赵六',
      salary: '7000',
      job: '销售'
    }
]);
let handleDelete=(index,row)=>{
  if (confirm("确定删除"+row.name+"的数据吗？")) {
    Employee.value.splice(index, 1);
  }
}
let handleEdit=(index,row)=>{


}
</script>

<style scoped>

</style>